package com.canal.admin.handler;

import com.canal.admin.exception.UserException;
import com.canal.admin.response.Result;
import com.canal.admin.response.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author yangbo
 * @Date 2019-03-18 14:48
 */
@ControllerAdvice
public class UserExceptionHandler {

    /**
     * 用户异常处理
     * @param e
     * @return
     */
    @ExceptionHandler(value = {UserException.class})
    @ResponseBody
    public Result userExceptionHandler(UserException e) {
        return ResultUtil.makeFailure(e.getCode(),e.getMessage());
    }
}
